<?php
//用户数据的添加
//
 header("Content-type:text/html;charset=utf-8");
	
	$username=$_POST[username];
	$password=$_POST[password];
	$phone=$_POST[phone];
	
	$link=mysql_connect("localhost","root","root") or die("不能连接到数据库服务器！可能是数据库服务器没有启动");
		$db_selected=mysql_select_db("db_ee",$link);
		mysql_query("set names utf8");
		$sql=mysql_query("select * from user where username='$username' and password='$password'",$link);
		
		if($sql[username])
		{
		echo "<script> alert('用户已经注册过');</script>";
	}
	else
	{
		$sql=mysql_query("INSERT INTO  user ( `username`, `password`, `phone`) VALUES ('$username','$password','$phone')");
		global $user;
		$user= $username;
	    session_start(); 
	    session_register(user); 
		echo "<script> alert('用户注册成功'); window.location.href='index.php';</script>";
		
		
	}
    
?>